<script>
function mo_form_sua(ten_dn){
	document.frmDLsua.ten_dn.value=ten_dn;
	document.frmDLsua.submit();
}

function thuchienxoa(){
	var f = document.frmdstv;
	var dstv = "";
	if(f.chkxoa.length != undefined){  //trong tinh trang co 2 cai de xoa
		var len = f.chkxoa.length;
		for( var i = 0; i < len; i++){
			if( f.chkxoa[i].checked){
				if( dstv == ""){
					dstv = f.chkxoa[i].value;
				}else dstv = dstv+","+f.chkxoa[i].value;
			}
		}
	}else 
	if(f.chkxoa.checked){
				dstv = f.chkxoa.value;
			}
	if(dstv == ""){
		alert('Vui lòng chọn thành viên cần xóa...');
		return false;
	}
	if(confirm('Bạn chắc muốn xóa thành viên này không?')){
		document.frmDLxoa.ten_dn.value = dstv;
		document.frmDLxoa.submit();
	}
}

function tim(id){
	var ten_dn = document.getElementById(id).value;
	//var regex=/^([0-9]*)$/;
	if(ten_dn == ""){
		document.getElementById('tb').innerHTML = "Vui lòng nhập tên đăng nhập!";
		//document.getElementById('msg').style.color = 'red';
	}
	else{
		document.getElementById('tb').innerHTML = "";
		xmlHttp = taoXmlHttpOb();
		xmlHttp.onreadystatechange=function() 
				{ 
				if(xmlHttp.readyState==4) 
				  { 
					document.getElementById("dstv").innerHTML = xmlHttp.responseText;
				  } 
				}
				xmlHttp.open("GET","thanh_vien/ds_thanh_vien_tim.php?ten_dn="+ten_dn,true);
			xmlHttp.send(null);
	}
}
</script>
////
<?php
	$p = new pager4;
	
	$limit = 20;
	
	$start = $p->find_start($limit);
	
	$count = mysql_num_rows(mysql_query("SELECT * FROM thanh_vien"));
	
	$pages = $p->find_pages($count, $limit);
	
	$sql="SELECT * FROM thanh_vien ORDER BY ten_dn LIMIT $start, $limit";
	$rs=mysql_query($sql);
?>
//nhung
<form name="frmdstv">
<div align="right">
<table cellspacing="10">
	<tr>
    	<td><div id="tb" style="color:#F00;"></div></td>
    	<td><b>Tên đăng nhập: </b></td>
        <td><input type="text" id="ten_tim" name="ten_tim" size="20"/></td>
        <td><input type="button" name="" value=" Tìm " onclick="tim('ten_tim')" class="button" /></td>
        <td><input type="button" class="button" onclick="location.href='index.php?noidung=dstv'" value=" Tất cả " /></td>
    </tr>
</table>
</div>
<br />
<table id="dstv" class="table" border="0" cellspacing="0" width="100%">
  <tr>
    <td colspan="8"><h2><b>Danh sách thành viên</b></h2></td>
  </tr>
  <tr>
    <td align="center" class="title_left">STT</td>
    <td align="center" class="title_row">TÊN ĐĂNG NHẬP</td>
    <td align="center" class="title_row">EMAIL</td>
    <td align="center" class="title_row">SỐ ĐIỆN THOẠI</td>
	<td align="center" class="title_row">ĐỊA CHỈ</td>
	<td align="center" class="title_row">QUYỀN</td>
    <td align="center" class="title_row"><font color="#00FF00">Sửa</font></td>
    <td align="center" class="title_row"><font color="#FF0000">Xóa</font></td>
  </tr>
<?php
	$i=0;
	while($rw=mysql_fetch_array($rs)){
		$i++;					
?>
  <tr>
    <td class="stt"><?php  echo $i; ?></td>
    <td class="data_row"><?php echo $rw['TEN_DN'] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw['EMAIL'] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw['SO_DT'] ?>&nbsp;</td>
    <td class="data_row"><?php echo $rw['DIA_CHI'] ?>&nbsp;</td>
    <td class="data_row">
	<?php
		if($rw['MS_QUYEN'] == 1){
			echo 'Quản trị';
		}
		else echo 'Thành viên';
	?>
    </td>
    <td align="center" class="data_row"><img src="images/edit.gif" border="0" onClick="mo_form_sua('<?php echo $rw['TEN_DN'];?>')"/></td>
    <td align="center" class="data_row"><input type="checkbox" name="chkxoa" value="<?php echo $rw['TEN_DN']; ?>  " /></td>
  </tr>
<?php
	} 
?>
 	<tr>
  		<td height="20" colspan="8"><b>Tổng số thành viên: <?php echo $count ?></b></td>
  	</tr>
</table>
<?php
	$page_list = $p->page_list($_GET['page'], $pages);
	echo "<div class='pagenavi'>".$page_list."</div>";
?>
	<div align="center"><input type="button" name="them" id="them" value="Thêm thành viên" class="button" onclick="location.href='index.php?noidung=ttv'"/>&nbsp;&nbsp;&nbsp;&nbsp;
	<input type="button" class="button" name="xoa" id="xoa" value="Xóa" onClick="thuchienxoa()"/></div><br />
<div align="center"><a href="index.php?noidung=ql">Trở về trang quản lý</a></div>
</form>
<form name="frmDLxoa" action="thanh_vien/xoa_thanh_vien.php" method="post">
<input type="hidden" name="ten_dn" value=""/></div>
</form>
<form name="frmDLsua" method="post" action="index.php?noidung=stv">
<input type="hidden" name="ten_dn" value="">
</form>

